package sjms.create.singleton;

public class Singleton_4 {
}


/**
 * 懒汉式——1
 *  优点：实现懒加载，线程安全
 *  缺点：synchroized 开销大
 */

class Singleton4{
    private static Singleton4 instance;

    private Singleton4(){}

    public static synchronized Singleton4 getInstance(){
        if(instance == null){
            instance = new Singleton4();
        }
        return instance;
    }
}
